/*Insert directory here*/

use PersInc1929-2022, clear
gen replace=.
replace replace=persinc if year==1960
egen value1960=sum(replace), by(statefip)
gen incfactor1960=persinc/value1960
drop value1960

replace replace=.
replace replace=persinc if year==1970
egen value1970=sum(replace), by(statefip)
gen incfactor1970=persinc/value1970
drop value1970

replace replace=.
replace replace=persinc if year==1980
egen value1980=sum(replace), by(statefip)
gen incfactor1980=persinc/value1980
drop value1980

replace replace=.
replace replace=persinc if year==1990
egen value1990=sum(replace), by(statefip)
gen incfactor1990=persinc/value1990
drop value1990

replace replace=.
replace replace=persinc if year==2000
egen value2000=sum(replace), by(statefip)
gen incfactor2000=persinc/value2000
drop value2000 replace persinc

reshape long incfactor, i(statefip year) j(censusyear)
drop if censusyear-year>26
rename year furnyear
save incfactorfurn2000, replace

rename furnyear year
drop if year>censusyear
drop if censusyear-year>10
drop if censusyear-year>9 & year!=1950
drop censusyear
save incfactor2000, replace
